TablesWriteToFile Subroutine

private subroutine TablesWriteToFile(tables, file, id)

Uses

write a collection of tables on file. If id is present, only the table corresponding to that id is written. Arguments: tables collection of tables to be exported file file to whom write the table

Arguments

Type IntentOptional Attributes Name
type(TableCollection), intent(in) :: tables
character(len=*), intent(in) :: file
character(len=*), intent(in), optional :: id

Variables

Type Visibility Attributes Name Initial
integer(kind=long), public :: i
integer(kind=short), public :: iunit

Source Code

SUBROUTINE TablesWriteToFile &
( tables, file, id )

USE Utilities, ONLY: &
!Imported routines:
GetUnit

IMPLICIT NONE

! Function arguments
! Scalar arguments with intent(in):
CHARACTER (LEN = *),  INTENT (IN) :: file
CHARACTER (LEN = *),  OPTIONAL, INTENT (IN) :: id

! Type defined arguments with intent (in):
TYPE (TableCollection), INTENT (IN) :: tables


!Local variables:
INTEGER (KIND = short) :: iunit
INTEGER (KIND = long)  :: i

!------------end of declaration------------------------------------------------

!get a free fortran unit
iunit = GetUnit ()
OPEN (UNIT = iunit, FILE = file, STATUS = "new")


IF ( PRESENT (id) ) THEN
  CALL TableWriteToUnit (  tables % elem ( TableSyncById (tables, id) ), iunit ) 
ELSE
  DO i = 1, tables % number
    CALL TableWriteToUnit (  tables % elem (i), iunit )
    WRITE(iunit,*)
  END DO
END IF

CLOSE (iunit)

END SUBROUTINE TablesWriteToFile